; The name of the installer
Name "Wordpress Comments Notifier"

; The file to write
OutFile "wp-comments-notifier-setup.0.11.exe"

; The default installation directory
InstallDir $PROGRAMFILES\wp-comments-notifier

; Registry key to check for directory (so if you install again, it will 
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\wp-comments-notifier" "Install_Dir"

; Request application privileges for Windows Vista
RequestExecutionLevel admin

;--------------------------------

; Pages

Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

; The stuff to install
Section "wp-comments-notifier (required)"

  SectionIn RO
  
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  
  ; Put file there
  File "..\release\wp-notifier.exe"
  File "..\release\Microsoft.VC90.CRT.manifest"
  File "..\release\msvcr90.dll"
  File "..\release\newcomments.wav"

  
  ; Write the installation path into the registry
  WriteRegStr HKLM SOFTWARE\wp-comments-notifier "Install_Dir" "$INSTDIR"
  WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "wpnotifier" "$INSTDIR\wp-notifier.exe"
  
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\wp-comments-notifier" "DisplayName" "wp-comments-notifier"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\wp-comments-notifier" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\wp-comments-notifier" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\wp-comments-notifier" "NoRepair" 1
  WriteUninstaller "uninstall.exe"
  
SectionEnd

; Optional section (can be disabled by the user)

Section "Start Menu Shortcuts"

  CreateDirectory "$SMPROGRAMS\wp-comments-notifier"
  CreateShortCut "$SMPROGRAMS\wp-comments-notifier\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\wp-comments-notifier\wp-notifier.lnk" "$INSTDIR\wp-notifier.exe" "" "$INSTDIR\wp-notifier.exe" 0
  
SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"
  
  ; Remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\wp-comments-notifier"
  DeleteRegKey HKLM SOFTWARE\wp-comments-notifier
  DeleteRegValue HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "wpnotifier"
 
  ; Remove files and uninstaller
  Delete $INSTDIR\wp-notifier.exe
  Delete $INSTDIR\newcomments.wav
  Delete $INSTDIR\Microsoft.VC90.CRT.manifest
  Delete $INSTDIR\msvcr90.dll
  Delete $INSTDIR\uninstall.exe

  ; Remove shortcuts, if any
  Delete "$SMPROGRAMS\wp-comments-notifier\*.*"

  ; Remove directories used
  RMDir "$SMPROGRAMS\wp-comments-notifier"
  RMDir "$INSTDIR"

SectionEnd
